package com.ruoyi.common.utils;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.ruoyi.common.utils.spring.SpringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author 48824
 */
public class WeChatUtils {

    private static String  miniAppId = SpringUtils.getBean(WeChatProperty.class).getAppId();

    private static  String  miniAppSecret =SpringUtils.getBean(WeChatProperty.class).getAppSecret();
    private static Logger logger = LoggerFactory.getLogger(WeChatUtils.class);

//    public static final String appId = "wx8e06d73b6858a591";
//    public static final String appSecret = "026aa1c2967131176150fa4d8d937868";


    /**
     * 小程序-微信用户相关配置
     */
    public static WxMaService getMiniWxMaService() {
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(miniAppId);
        config.setSecret(miniAppSecret);
        config.setMsgDataFormat("JSON");
        WxMaService wxMaService = new WxMaServiceImpl();
        wxMaService.setWxMaConfig(config);
        return wxMaService;
    }
}
